package com.itheima.fileoutputstream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;

public class Tet {

    public static void main(String[] args) throws Exception {

        //1.创建文件字节输出流管道与目标文件对象接通
        //OutputStream os = new FileOutputStream("io\\src\\tiger-out.txt");   //覆盖
        OutputStream os = new FileOutputStream("io\\src\\tiger-out.txt",true);  //追加

        //2.写入数据：public void write(int b)
        os.write(97);
        os.write('c');
        //os.write('许');  //乱码
        os.write("\r\n".getBytes());        // 换行

        //3.写一个字节数组：public void write(byte[] b)
        //byte[] bytes = {97,98,99,100,101,102};
        byte[] bytes = "hgj绝对是768".getBytes();
        os.write(bytes);
        os.write("\r\n".getBytes());        // 换行


        //4.写一个字节数组的一部分：public void write(byte[] b, int off, int len)
        os.write(bytes,0,3);
        os.write("\r\n".getBytes());        // 换行

        //5.关闭管道
        os.close();


    }
}
